home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC Gamer (Italian) 30
/
PC Gamer IT CD 30 1-2.iso
/
MOTS
/
GAMEDATA
/
RESOURCE
/
JKMRES.GOO
/
cog_00_door.cog
< prev
next >
Wrap
Text File
|
1998-02-25
|
3KB
|
113 lines
# Jedi Knight Cog Script
#
# 00_Door.cog
#
# Generic Door Script
#
# [IS]
#
# (C) 1997 LucasArts Entertainment Co. All Rights Reserved
# ========================================================================================
symbols
message startup
message activate
message arrived
message timer
message blocked
thing door0 linkid=0 mask=0x405
thing door1 linkid=1 mask=0x405
thing door2 linkid=2 mask=0x405
thing door3 linkid=3 mask=0x405
float moveSpeed=8.0
float sleepTime=2.0
float lightValue=0.5
sector doorSector local
int numDoors=0 local
int doorStatus local
int moveStatus local
int i local
end
# ========================================================================================
code
startup:
for (i=0; i<=3; i=i+1)
if (door0[i] >= 0) numDoors = numDoors + 1;
doorSector = GetThingSector(door0);
SetSectorAdjoins(doorSector, 0);
SetSectorLight(doorSector, lightValue, 0.0); // add some light to door sector
return;
# ........................................................................................
activate:
call CheckStatus;
if (moveStatus) return;
if (doorStatus == 0) { // all pieces are at frame 0
SetSectorAdjoins(doorSector, 1);
call OpenDoors;
}
return;
# ........................................................................................
arrived:
call CheckStatus;
if (moveStatus) return;
if (doorStatus == numDoors) { // all pieces are at frame 1
SetTimer(sleepTime);
} else if (doorStatus == 0) { // all pieces are at frame 0
SetSectorAdjoins(doorSector, 0);
}
return;
# ........................................................................................
blocked:
call OpenDoors;
return;
# ........................................................................................
timer:
call CloseDoors;
return;
# ........................................................................................
OpenDoors:
for (i=0; i<=3; i=i+1)
if (door0[i] >= 0) MoveToFrame(door0[i], 1, moveSpeed);
return;
# ........................................................................................
CloseDoors:
for (i=0; i<=3; i=i+1)
if (door0[i] >= 0) MoveToFrame(door0[i], 0, moveSpeed);
return;
# ........................................................................................
CheckStatus:
moveStatus = 0;
doorStatus = 0;
for (i=0; i<=3; i=i+1) {
if (door0[i] >= 0) {
moveStatus = moveStatus + IsThingMoving(door0[i]);
doorStatus = doorStatus + GetCurFrame(door0[i]);
}
}
return;
end